using Domain.Database;
using System.Data.Entity.ModelConfiguration;

namespace Domain.Mapping
{
    public class UserInfoMap : EntityTypeConfiguration<UserInfo>
    {
        public UserInfoMap()
        {
            // Primary Key
            this.HasKey(t => new { t.UserInfoId });

            // Properties
            this.Property(t => t.UserInfoId)
                .IsRequired()
                .HasMaxLength(32);

            this.Property(t => t.LoginName)
                .IsRequired()
                .HasMaxLength(25);

            this.Property(t => t.LoginPassword)
                .IsRequired()
                .HasMaxLength(25);

            this.Property(t => t.Email)
                .HasMaxLength(100);

            this.Property(t => t.Phone)
                .HasMaxLength(100);

            this.Property(t => t.Homeplace)
                .HasMaxLength(25);

            this.Property(t => t.Address)
                .HasMaxLength(100);

            this.Property(t => t.Nickname)
                .HasMaxLength(25);

            this.Property(t => t.Headphoto)
                .HasMaxLength(300);

            this.Property(t => t.QQ)
                .HasMaxLength(25);

            this.Property(t => t.Hobby)
                .HasMaxLength(50);

            this.Property(t => t.Sign)
                .HasMaxLength(50);

            this.Property(t => t.LastLoginIp)
                .HasMaxLength(25);

            // Table & Column Mappings
            this.ToTable("UserInfo");
            this.Property(t => t.UserInfoId).HasColumnName("UserInfoId");
            this.Property(t => t.LoginName).HasColumnName("LoginName");
            this.Property(t => t.LoginPassword).HasColumnName("LoginPassword");
            this.Property(t => t.Sex).HasColumnName("Sex");
            this.Property(t => t.Birthday).HasColumnName("Birthday");
            this.Property(t => t.Age).HasColumnName("Age");
            this.Property(t => t.Email).HasColumnName("Email");
            this.Property(t => t.Phone).HasColumnName("Phone");
            this.Property(t => t.Homeplace).HasColumnName("Homeplace");
            this.Property(t => t.Address).HasColumnName("Address");
            this.Property(t => t.Nickname).HasColumnName("Nickname");
            this.Property(t => t.Headphoto).HasColumnName("Headphoto");
            this.Property(t => t.QQ).HasColumnName("QQ");
            this.Property(t => t.Hobby).HasColumnName("Hobby");
            this.Property(t => t.Sign).HasColumnName("Sign");
            this.Property(t => t.LastLoginTime).HasColumnName("LastLoginTime");
            this.Property(t => t.LastLoginIp).HasColumnName("LastLoginIp");
            this.Property(t => t.IsForbidden).HasColumnName("IsForbidden");
            this.Property(t => t.IsSuper).HasColumnName("IsSuper");
            this.Property(t => t.AddTime).HasColumnName("AddTime");
            this.Property(t => t.ModifyTime).HasColumnName("ModifyTime");
        }
    }
}
